.TH std::condition_variable_any 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::condition_variable_any \- std::condition_variable_any

.SH Synopsis
   Defined in header <condition_variable>
   class condition_variable_any;           \fI(since C++11)\fP

   The condition_variable_any class is a generalization of std::condition_variable.
   Whereas std::condition_variable works only on std::unique_lock<std::mutex>,
   condition_variable_any can operate on any lock that meets the BasicLockable
   requirements.

   See std::condition_variable for the description of the semantics of condition
   variables.

   The class std::condition_variable_any is a StandardLayoutType. It is not
   CopyConstructible, MoveConstructible, CopyAssignable, or MoveAssignable.

   If the lock is std::unique_lock<std::mutex>, std::condition_variable may provide
   better performance.

.SH Member functions

   constructor   constructs the object
                 \fI(public member function)\fP
   destructor    destructs the object
                 \fI(public member function)\fP
   operator=     not copy-assignable
   [deleted]     \fI(public member function)\fP
.SH Notification
   notify_one    notifies one waiting thread
                 \fI(public member function)\fP
   notify_all    notifies all waiting threads
                 \fI(public member function)\fP
.SH Waiting
   wait          blocks the current thread until the condition variable is awakened
                 \fI(public member function)\fP
                 blocks the current thread until the condition variable is awakened or
   wait_for      after the specified timeout duration
                 \fI(public member function)\fP
                 blocks the current thread until the condition variable is awakened or
   wait_until    until specified time point has been reached
                 \fI(public member function)\fP

.SH Notes

   std::condition_variable_any can be used with std::shared_lock in order to wait on a
   std::shared_mutex in shared ownership mode.

   A possible use for std::condition_variable_any with custom Lockable types is to
   provide convenient interruptible waits: the custom lock operation would both lock
   the associated mutex as expected, and also perform the necessary setup to notify
   this condition variable when the interrupting signal is received.^[1]

.SH See also

   condition_variable provides a condition variable associated with a std::unique_lock
   \fI(C++11)\fP            \fI(class)\fP

.SH External links

    1. ↑ Anthony Williams (2012, 1st ed./ 2019, 2nd ed.), “C++ Concurrency in Action”,
       9.2.4 “Interrupting a wait on std::condition_variable_any”.
